<%@ page contentType="text/html;charset=utf-8"%>
<html>
<head>
<meta charset="UTF-8">
<title>Table</title>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/js/layui-v1.0.9_rls/layui/css/layui.css"
	media="all" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/js/layui-v1.0.9_rls/layui/css/global.css"
	media="all">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/js/plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/js/layui-v1.0.9_rls/layui/css/table.css" />

<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/layui-v1.0.9_rls/layui/layui.js"></script>
	
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jquery-1.8.0.min.js"></script>
	

<script type="text/javascript">
	layui.config({
		base : 'js/layui-v1.0.9_rls/layui/js/'
	});

	layui.use([ 'upload', 'form', 'laydate' ], function() {
		form = layui.form();
		//监听提交
		form.on('submit(saveBtn)', function(data) {

			//获取参数
			var city = data.field.city;
			alert(city);

			return false;
		});

		var upload = layui.upload;
		//上传文件
		layui.upload({
			url : '<%=request.getContextPath()%>/rms/uploadAttach'
			//,elem: '#test' //指定原始元素，默认直接查找class="layui-upload-file"
			,
			title : '上传文件',
			ext : 'jpg|png|gif|rar|doc|docx|xls|xlsx|zip',
			method : 'post' //上传接口的http类型
			//上传前
			,
			before : function(input) {
			
				//返回的参数item，即为当前的input DOM对象
				//console.log('文件上传中');
			},
			success : function(res) {
			
				var fileName = decodeURI(res.fileName);
				var fileStr = "<a href='javascript:void(0)' onclick='downLoadFile()'>"+fileName+"</a>";
				alert(fileStr);
				$("#attachFileDiv").append(fileStr);
				alert(22);
				//alert(res.retCode);
				//console.log(res); //如：{"code":0 ,"msg":"","url":"http://cdn.abc.com/123.jpg"'} 
				//alert(res.url);
			}
		});

	});

	//反馈按钮处理
	function cancel() {

		parent._closeTab("测试");
	}

	function addTabTest() {
		parent._addTab("测试2", "http://www.sina.com.cn");
	}
	
	function downLoadFile(){
		alert(1);
	}
</script>
</head>
<body style="background: white">
	<div style="margin: 15px;">

		<form class="layui-form">

			<div class="layui-form-item">
				<label class="layui-form-label">输入框</label>
				<div class="layui-input-block">
					<input type="text" name="" placeholder="请输入" autocomplete="off"
						class="layui-input" value="ddd">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">密码框</label>
				<div class="layui-input-inline">
					<input type="password" name="password" required
						lay-verify="required" placeholder="请输入密码" autocomplete="off"
						class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-aux">辅助文字</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">选择框</label>
				<div class="layui-input-block">
					<select id="city" name="city" lay-verify="required">
						<option value=""></option>
						<option value="0">北京</option>
						<option value="1" selected>上海</option>
						<option value="2">广州</option>
						<option value="3">深圳</option>
						<option value="4">杭州</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">复选框</label>
				<div class="layui-input-block">
					<input type="checkbox" name="like[write]" title="写作" checked>
					<input type="checkbox" name="like[read]" title="阅读" checked>
					<input type="checkbox" name="like[dai]" title="发呆">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">开关</label>
				<div class="layui-input-block">
					<input type="checkbox" name="switch" lay-skin="switch">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">单选框</label>
				<div class="layui-input-block">
					<input type="radio" name="sex" value="男" title="男" checked>
					<input type="radio" name="sex" value="女" title="女">
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">文本域</label>
				<div class="layui-input-block">
					<textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
				</div>
			</div>

			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">需求附件</label>
				<div class="layui-input-block">
					<input type="file" name="file" class="layui-upload-file"
						lay-type="file">
				</div>
				<div class="layui-input-block" id="attachFileDiv">
					
				</div>
			</div>



			<div class="layui-form-item">
				<div class="layui-input-block">
					<!-- lay-filter就是id属性 -->
					<button class="layui-btn" lay-submit="" lay-filter="saveBtn">提交</button>
					<input type="button" class="layui-btn " onclick="cancel()"
						value="取消"></input> <input type="button" class="layui-btn "
						onclick="addTabTest()" value="添加tab"></input>
				</div>
			</div>

		</form>

	</div>
</body>
</html>